Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 1 | git-remote(1) |
| 2 | ============ |
| 3 | |
| 4 | NAME |
| 5 | ---- |
Junio C Hamano | 5b3533d | 2014-02-27 23:07:15 | [diff] [blame] | 6 | git-remote - Manage set of tracked repositories |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 7 | |
| 8 | |
| 9 | SYNOPSIS |
| 10 | -------- |
| 11 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 12 | 'git remote' [-v | --verbose] |
Junio C Hamano | 3d1b5a1 | 2013-05-17 23:34:02 | [diff] [blame] | 13 | 'git remote add' [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url> |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 14 | 'git remote rename' <old> <new> |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 15 | 'git remote remove' <name> |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 16 | 'git remote set-head' <name> (-a | --auto | -d | --delete | <branch>) |
Junio C Hamano | e0238c2 | 2012-02-23 22:45:50 | [diff] [blame] | 17 | 'git remote set-branches' [--add] <name> <branch>... |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 18 | 'git remote get-url' [--push] [--all] <name> |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 19 | 'git remote set-url' [--push] <name> <newurl> [<oldurl>] |
| 20 | 'git remote set-url --add' [--push] <name> <newurl> |
| 21 | 'git remote set-url --delete' [--push] <name> <url> |
Junio C Hamano | 5a6d5f7 | 2013-05-01 23:37:03 | [diff] [blame] | 22 | 'git remote' [-v | --verbose] 'show' [-n] <name>... |
| 23 | 'git remote prune' [-n | --dry-run] <name>... |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 24 | 'git remote' [-v | --verbose] 'update' [-p | --prune] [(<group> | <remote>)...] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 25 | |
| 26 | DESCRIPTION |
| 27 | ----------- |
| 28 | |
| 29 | Manage the set of repositories ("remotes") whose branches you track. |
| 30 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 31 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 32 | OPTIONS |
| 33 | ------- |
| 34 | |
| 35 | -v:: |
| 36 | --verbose:: |
| 37 | Be a little more verbose and show remote url after name. |
Junio C Hamano | bf984de | 2009-11-23 06:11:19 | [diff] [blame] | 38 | NOTE: This must be placed between `remote` and `subcommand`. |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 39 | |
| 40 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 41 | COMMANDS |
| 42 | -------- |
| 43 | |
| 44 | With no arguments, shows a list of existing remotes. Several |
| 45 | subcommands are available to perform operations on the remotes. |
| 46 | |
| 47 | 'add':: |
| 48 | |
| 49 | Adds a remote named <name> for the repository at |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 50 | <url>. The command `git fetch <name>` can then be used to create and |
| 51 | update remote-tracking branches <name>/<branch>. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 52 | + |
| 53 | With `-f` option, `git fetch <name>` is run immediately after |
| 54 | the remote information is set up. |
| 55 | + |
Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 56 | With `--tags` option, `git fetch <name>` imports every tag from the |
| 57 | remote repository. |
| 58 | + |
| 59 | With `--no-tags` option, `git fetch <name>` does not import tags from |
| 60 | the remote repository. |
| 61 | + |
Junio C Hamano | 6bf68cf | 2015-03-06 23:46:29 | [diff] [blame] | 62 | By default, only tags on fetched branches are imported |
| 63 | (see linkgit:git-fetch[1]). |
| 64 | + |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 65 | With `-t <branch>` option, instead of the default glob |
| 66 | refspec for the remote to track all branches under |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 67 | the `refs/remotes/<name>/` namespace, a refspec to track only `<branch>` |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 68 | is created. You can give more than one `-t <branch>` to track |
Junio C Hamano | 67fad6d | 2007-05-06 08:53:12 | [diff] [blame] | 69 | multiple branches without grabbing all branches. |
Junio C Hamano | 17dde0e | 2007-02-26 09:50:21 | [diff] [blame] | 70 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 71 | With `-m <master>` option, a symbolic-ref `refs/remotes/<name>/HEAD` is set |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 72 | up to point at remote's `<master>` branch. See also the set-head command. |
Junio C Hamano | 58155b4 | 2007-09-15 07:46:14 | [diff] [blame] | 73 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 74 | When a fetch mirror is created with `--mirror=fetch`, the refs will not |
Junio C Hamano | ee3adc3 | 2011-04-06 19:53:38 | [diff] [blame] | 75 | be stored in the 'refs/remotes/' namespace, but rather everything in |
| 76 | 'refs/' on the remote will be directly mirrored into 'refs/' in the |
| 77 | local repository. This option only makes sense in bare repositories, |
| 78 | because a fetch would overwrite any local commits. |
| 79 | + |
Junio C Hamano | b76a686 | 2012-05-02 22:02:46 | [diff] [blame] | 80 | When a push mirror is created with `--mirror=push`, then `git push` |
| 81 | will always behave as if `--mirror` was passed. |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 82 | |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 83 | 'rename':: |
| 84 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 85 | Rename the remote named <old> to <new>. All remote-tracking branches and |
Junio C Hamano | 2836349 | 2008-11-14 08:26:31 | [diff] [blame] | 86 | configuration settings for the remote are updated. |
| 87 | + |
| 88 | In case <old> and <new> are the same, and <old> is a file under |
| 89 | `$GIT_DIR/remotes` or `$GIT_DIR/branches`, the remote is converted to |
| 90 | the configuration file format. |
| 91 | |
Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 92 | 'remove':: |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 93 | 'rm':: |
| 94 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 95 | Remove the remote named <name>. All remote-tracking branches and |
Junio C Hamano | 4fd58d4 | 2007-09-30 00:51:14 | [diff] [blame] | 96 | configuration settings for the remote are removed. |
| 97 | |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 98 | 'set-head':: |
| 99 | |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 100 | Sets or deletes the default branch (i.e. the target of the |
| 101 | symbolic-ref `refs/remotes/<name>/HEAD`) for |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 102 | the named remote. Having a default branch for a remote is not required, |
| 103 | but allows the name of the remote to be specified in lieu of a specific |
| 104 | branch. For example, if the default branch for `origin` is set to |
| 105 | `master`, then `origin` may be specified wherever you would normally |
| 106 | specify `origin/master`. |
| 107 | + |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 108 | With `-d` or `--delete`, the symbolic ref `refs/remotes/<name>/HEAD` is deleted. |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 109 | + |
Junio C Hamano | 369e340 | 2013-10-15 18:40:25 | [diff] [blame] | 110 | With `-a` or `--auto`, the remote is queried to determine its `HEAD`, then the |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 111 | symbolic-ref `refs/remotes/<name>/HEAD` is set to the same branch. e.g., if the remote |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 112 | `HEAD` is pointed at `next`, "`git remote set-head origin -a`" will set |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 113 | the symbolic-ref `refs/remotes/origin/HEAD` to `refs/remotes/origin/next`. This will |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 114 | only work if `refs/remotes/origin/next` already exists; if not it must be |
| 115 | fetched first. |
| 116 | + |
Junio C Hamano | 360e3a1 | 2011-07-13 23:51:56 | [diff] [blame] | 117 | Use `<branch>` to set the symbolic-ref `refs/remotes/<name>/HEAD` explicitly. e.g., "git |
| 118 | remote set-head origin master" will set the symbolic-ref `refs/remotes/origin/HEAD` to |
Junio C Hamano | d257cff | 2009-03-18 05:27:16 | [diff] [blame] | 119 | `refs/remotes/origin/master`. This will only work if |
| 120 | `refs/remotes/origin/master` already exists; if not it must be fetched first. |
| 121 | + |
| 122 | |
Junio C Hamano | f5de4cf | 2010-06-19 00:33:17 | [diff] [blame] | 123 | 'set-branches':: |
| 124 | |
| 125 | Changes the list of branches tracked by the named remote. |
| 126 | This can be used to track a subset of the available remote branches |
| 127 | after the initial setup for a remote. |
| 128 | + |
| 129 | The named branches will be interpreted as if specified with the |
| 130 | `-t` option on the 'git remote add' command line. |
| 131 | + |
| 132 | With `--add`, instead of replacing the list of currently tracked |
| 133 | branches, adds to that list. |
| 134 | |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 135 | 'get-url':: |
| 136 | |
| 137 | Retrieves the URLs for a remote. Configurations for `insteadOf` and |
| 138 | `pushInsteadOf` are expanded here. By default, only the first URL is listed. |
| 139 | + |
| 140 | With '--push', push URLs are queried rather than fetch URLs. |
| 141 | + |
| 142 | With '--all', all URLs for the remote will be listed. |
| 143 | |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 144 | 'set-url':: |
| 145 | |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 146 | Changes URLs for the remote. Sets first URL for remote <name> that matches |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 147 | regex <oldurl> (first URL if no <oldurl> is given) to <newurl>. If |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 148 | <oldurl> doesn't match any URL, an error occurs and nothing is changed. |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 149 | + |
| 150 | With '--push', push URLs are manipulated instead of fetch URLs. |
| 151 | + |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 152 | With '--add', instead of changing existing URLs, new URL is added. |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 153 | + |
Junio C Hamano | c355030 | 2015-02-18 22:34:11 | [diff] [blame] | 154 | With '--delete', instead of changing existing URLs, all URLs matching |
| 155 | regex <url> are deleted for remote <name>. Trying to delete all |
| 156 | non-push URLs is an error. |
| 157 | + |
| 158 | Note that the push URL and the fetch URL, even though they can |
| 159 | be set differently, must still refer to the same place. What you |
| 160 | pushed to the push URL should be what you would see if you |
| 161 | immediately fetched from the fetch URL. If you are trying to |
| 162 | fetch from one place (e.g. your upstream) and push to another (e.g. |
| 163 | your publishing repository), use two separate remotes. |
| 164 | |
Junio C Hamano | 57827fb | 2010-01-23 03:02:50 | [diff] [blame] | 165 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 166 | 'show':: |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 167 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 168 | Gives some information about the remote <name>. |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 169 | + |
| 170 | With `-n` option, the remote heads are not queried first with |
| 171 | `git ls-remote <name>`; cached information is used instead. |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 172 | |
| 173 | 'prune':: |
| 174 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 175 | Deletes all stale remote-tracking branches under <name>. |
Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 176 | These stale branches have already been removed from the remote repository |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 177 | referenced by <name>, but are still locally available in |
| 178 | "remotes/<name>". |
Junio C Hamano | 401939f | 2007-07-01 06:34:30 | [diff] [blame] | 179 | + |
Junio C Hamano | 9f88386 | 2009-08-11 06:23:52 | [diff] [blame] | 180 | With `--dry-run` option, report what branches will be pruned, but do not |
Junio C Hamano | 6fb124c | 2008-06-13 10:04:01 | [diff] [blame] | 181 | actually prune them. |
Junio C Hamano | 0bbd467 | 2007-02-20 04:52:14 | [diff] [blame] | 182 | |
| 183 | 'update':: |
| 184 | |
Junio C Hamano | 118d277 | 2007-02-21 20:24:10 | [diff] [blame] | 185 | Fetch updates for a named set of remotes in the repository as defined by |
| 186 | remotes.<group>. If a named group is not specified on the command line, |
Junio C Hamano | 9f88386 | 2009-08-11 06:23:52 | [diff] [blame] | 187 | the configuration parameter remotes.default will be used; if |
Junio C Hamano | 361c133 | 2007-11-14 12:17:22 | [diff] [blame] | 188 | remotes.default is not defined, all remotes which do not have the |
Junio C Hamano | 118d277 | 2007-02-21 20:24:10 | [diff] [blame] | 189 | configuration parameter remote.<name>.skipDefaultUpdate set to true will |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 190 | be updated. (See linkgit:git-config[1]). |
Junio C Hamano | 98e32c3 | 2009-04-13 02:39:53 | [diff] [blame] | 191 | + |
| 192 | With `--prune` option, prune all the remotes that are updated. |
Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 193 | |
Junio C Hamano | ee1e428 | 2007-02-04 08:32:04 | [diff] [blame] | 194 | |
| 195 | DISCUSSION |
| 196 | ---------- |
| 197 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 198 | The remote configuration is achieved using the `remote.origin.url` and |
| 199 | `remote.origin.fetch` configuration variables. (See |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 200 | linkgit:git-config[1]). |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 201 | |
| 202 | Examples |
| 203 | -------- |
| 204 | |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 205 | * Add a new remote, fetch, and check out a branch from it |
| 206 | + |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 207 | ------------ |
| 208 | $ git remote |
| 209 | origin |
| 210 | $ git branch -r |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 211 | origin/HEAD -> origin/master |
| 212 | origin/master |
| 213 | $ git remote add staging git://git.kernel.org/.../gregkh/staging.git |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 214 | $ git remote |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 215 | origin |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 216 | staging |
| 217 | $ git fetch staging |
| 218 | ... |
| 219 | From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging |
| 220 | * [new branch] master -> staging/master |
| 221 | * [new branch] staging-linus -> staging/staging-linus |
| 222 | * [new branch] staging-next -> staging/staging-next |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 223 | $ git branch -r |
Junio C Hamano | a195230 | 2013-07-01 21:31:18 | [diff] [blame] | 224 | origin/HEAD -> origin/master |
| 225 | origin/master |
| 226 | staging/master |
| 227 | staging/staging-linus |
| 228 | staging/staging-next |
| 229 | $ git checkout -b staging staging/master |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 230 | ... |
| 231 | ------------ |
| 232 | |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 233 | * Imitate 'git clone' but track only selected branches |
Junio C Hamano | 6ac2f14 | 2007-03-01 01:24:56 | [diff] [blame] | 234 | + |
| 235 | ------------ |
| 236 | $ mkdir project.git |
| 237 | $ cd project.git |
| 238 | $ git init |
| 239 | $ git remote add -f -t master -m master origin git://example.com/git.git/ |
| 240 | $ git merge origin |
| 241 | ------------ |
| 242 | |
| 243 | |
Junio C Hamano | 9049d91 | 2008-05-29 02:09:50 | [diff] [blame] | 244 | SEE ALSO |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 245 | -------- |
Junio C Hamano | 35738e8 | 2008-01-07 07:55:46 | [diff] [blame] | 246 | linkgit:git-fetch[1] |
| 247 | linkgit:git-branch[1] |
| 248 | linkgit:git-config[1] |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 249 | |
Junio C Hamano | 1d3a6c7 | 2007-01-09 11:13:47 | [diff] [blame] | 250 | GIT |
| 251 | --- |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 252 | Part of the linkgit:git[1] suite |